const models = import.meta.glob('@/views/**/*.vue')
import layout from '@/layout/main.vue'
export function setRouters(val: any) {
  setMenu(val, false)
  return val
}
function Reg(path: string) {
  return new RegExp(path + '/index.vue')
}
function setMenu(val: any, type: boolean) {
  return
  for (let i = 0; i < val.length; i++) {
    val[i].component = layout
    if (val[i].children.length == 0) {
      if (type) {
        // 处理非一级
        for (let key in models) {
          if (Reg(val[i].path).test(key)) {
            if (val[i].children.length > 0) {
              // 多级
              setMenu(val[i].children, true)
            } else {
              // 二级
              val[i].path = '/' + val[i].params + '/' + val[i].path
              val[i].component = models[key]
            }
          }
        }
      } else {
        // 处理首页
        if (val[i].path == '/') {
          for (let key in models) {
            if (Reg('home').test(key)) {
              val[i].children = [
                {
                  icon: '',
                  path: '/home',
                  component: models[key],
                  meta: {
                    title: '首页',
                  },
                },
              ]
            }
          }
        } else {
          // 处理一级
          for (let key in models) {
            if (Reg(val[i].path).test(key)) {
              val[i].children = [
                {
                  icon: '',
                  path: val[i].path,
                  component: models[key],
                  meta: {
                    title: val[i].meta.title,
                  },
                },
              ]
            }
          }
        }
      }
    } else {
      setMenu(val[i].children, true)
    }
  }
}
